<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>最常用出租屋管理系统</title>
  <!-- 导入样式 -->
  <link rel="stylesheet" href="__CDN__/element/index.css" />
  <link rel="stylesheet" href="__STATIC__/css/backend.css">
  <link rel="stylesheet" href="__CDN__/print/print.css" type="text/css">
  <link rel="stylesheet" href="https://ks3-cn-beijing.ksyun.com/vform3/render.style.css?t=20220129">
  <!-- axios -->
  <script src="__STATIC__/js/axios.min.js"></script>
  <!-- 导入 Vue -->
  <script src="__CDN__/vue/3.2.36/vue.global.js"></script>
  <!-- 导入组件库 -->
  <script src="__CDN__/element/index.js"></script>
  <!-- 导入中文 -->
  <script src="__CDN__/element/zh-cn.js"></script>
  <!-- 导入antv g2 -->
  <script src="__CDN__/antv/g2.min.js"></script>
  <!-- <script src="https://gw.alipayobjects.com/os/lib/antv/g2/4.2.5/dist/g2.min.js"></script> -->
  <!-- 导入printJS -->
  <script src="__CDN__/print/print.js"></script>
  <!-- 导入中文 -->
  <script type="text/javascript" src="https://ks3-cn-beijing.ksyun.com/vform3/render.umd.js?t=20220129"></script>
  <script type="text/javascript" src="__STATIC__/js/vform.js"></script>
  <script type="text/javascript"
    src="__STATIC__/js/main.js?{if $Think.env.app_debug}_={:time()}{else /}v={$Think.config.tpadmin.version}{/if}"></script>
</head>

<body>
  <div id="app" v-cloak>
    <el-container>
      {include file="common/pub/aside" /}
      <el-container>
        <el-header>
          {include file="common/pub/header" /}
        </el-header>
        <el-main>
          {block name="main"}{/block}
        </el-main>
      </el-container>
    </el-container>
  </div>
  {block name="script"}{/block}
  <script>
    this.token = '{$layout_token}';
    const common_data = {
      isCollapse: false,
      aside_width: '230px',
      houseDef: '',
      houseList: [],
      passwordVisible: false,
      pawwordData: {},
      pawwordRules: {
        password: [{ required: true, message: '请输入', trigger: 'blur' }],
        password2: [{ required: true, message: '请输入', trigger: 'blur' }],
      },
    }

    function common_f() {
      return {
        hideAside: function () {
          this.isCollapse = true
          this.aside_width = '60px'
        },
        showAside: function () {
          this.isCollapse = false
          this.aside_width = '230px'
        },
        onLogout: function () {
          let that = this;
          axiosPost('{:url("Index/logout")}', {}).then(response => {
            if (response.state == 'success') {
              that.$message.success(response.msg);
              window.location.href = '{:url("index/login")}';
            } else {
              that.$message({
                message: response.msg, type: response.state
              });
            }
          });
        },
        changePassword: function () {
          this.passwordVisible = true
          this.pawwordData = {};
          if (this.$refs['pawwordData']) {
            this.$refs['pawwordData'].resetFields();
          }
        },
        passwordSave: function () {
          let that = this;
          let validation = false;
          this.$refs['pawwordData'].validate((valid) => {
            if (valid) {
              validation = true;
            }
          });
          if (validation) {
            if (this.pawwordData.password === this.pawwordData.password2) {
              axiosPost('{:url("Index/password")}', this.pawwordData).then(response => {
                if (response.state == 'success') {
                  that.$message.success(response.msg);
                  that.passwordVisible = false
                } else {
                  that.$message({
                    message: response.msg, type: response.state
                  });
                }
              });
            } else {
              this.$message.warning('两次输入的密码不一致')
            }
          }
        },
        queryHouse: function () {
          let that = this;
          axiosGet("{:url('house.property/query')}").then(response => {
            if (response.code == 1) {
              that.houseList = response.data;
              for (let index = 0; index < that.houseList.length; index++) {
                if (that.houseList[index].firstly == 'Y') {
                  that.houseDef = that.houseList[index].id;
                  break;
                }
              }
            } else {
              that.$message.error('系统出错了!!!');
            }
          });
        },
        changeHouse: function (val) {
          let that = this;
          axiosPost("{:url('house.property/sort')}", { 'id': val }).then(response => {
            if (response.state == 'success') {
              that.$message.success(response.msg)
              location.reload();
            } else {
              that.$message({
                message: response.msg, type: response.state
              });
            }
          });
        },
      }
    }

    const App = {
      data: function () {
        return Object.assign(common_data, data)
      },
      methods: Object.assign(common_f(), f()),
      mounted: function () {
        this.init();
        this.queryHouse();
      }
    };

    const app = Vue.createApp(App);
    app.use(ElementPlus, { size: 'mini', zIndex: 3000, locale: ElementPlusLocaleZhCn, });
    app.use(VFormRender)
    app.mount("#app");
  </script>
</body>

</html>